package compiler;

import java.util.ArrayList;

import returnTypes.Status;
import room.Room;
import tester.RoomTester;
import wall.Wall;

public class CreateRoom implements Create{
	public Object ExecutCommand(ArrayList<String> toDo)
	{
		RoomTester tester=new RoomTester();
		String roomName=toDo.get(0);
		ArrayList<Wall> walls=new ArrayList<Wall>();
		Room returnRoom=null;
		for(int i=0;i<Compiler.allWalls.size();i++)
		{
			for(int j=2;j<toDo.size();j++)
			if (Compiler.allWalls.get(i).getName().equals(toDo.get(j).substring(0, toDo.get(j).length()-1))){
				if (Compiler.allWalls.get(i).getState()==Status.FREE){
					walls.add(Compiler.allWalls.get(i));}	

			}
			
		}
		returnRoom=tester.createRoom(walls, Room.getRoomID());
		returnRoom.setRoomName(roomName);
		returnRoom.setState(Status.FREE);
		return returnRoom;
	}
}
